using System;
using System.Runtime.InteropServices;

namespace FormWithConsole {
  internal static class NativeMethods {
    [DllImport("kernel32.dll", SetLastError = true)]
    internal static extern int AllocConsole ();

    [DllImport("kernel32.dll", SetLastError = true)]
    internal static extern int FreeConsole ();

    [DllImport("kernel32.dll")]
    internal static extern IntPtr GetConsoleWindow ();

    [DllImport("user32.dll")]
    internal static extern bool ShowWindow (IntPtr hWnd, int nCmdShow);

    public const int SW_HIDE = 0;
  }
}
